const Validator = require('fastest-validator');
module.exports = {
    validate(data, rules)
    {
        let v = new Validator();
        return v.validate(data, rules);
    },
    stringToJson(string)
    {
        try
        {
            if(string.length<2) return false;
            return JSON.parse(string);
        } catch (e)
        {
            return false;
        }
    },nowTimestamp(){
        return (Date.parse(new Date()))/1000;
    },in_array(array,val){
        for(let i=0;i<array.length;i++){
            if(array[i]==val)return true;
        }
        return false;
    }
};